/**
 * Project: complex.myapp
 * 
 * File Created at 2010-6-7
 * $Id$
 * 
 * Copyright 2008 Alibaba.com Croporation Limited.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * Alibaba Company. ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with Alibaba.com.
 */
package com.complex.myapp;

import java.io.BufferedReader;
import java.io.FileReader;
import java.util.regex.MatchResult;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @description:XXX
 * @author gaoliang
 * @date 2010-6-7
 * @version 1.0
 */
public class ReadEnglishFile {
    public static void main(String[] args) {
        try {
            BufferedReader in = new BufferedReader(new FileReader("d:/new_1.txt"));
            String str = "1. file n. 文件；v. 保存文件 ";
            String s;
            
            //匹配器
            Pattern p = Pattern.compile("\\s*\\d+\\.\\s[a-zA-Z]*\\s.*");
            Pattern p1 = Pattern.compile("[a-zA-Z]*");
            while((s = in.readLine()) != null){
                Matcher m = p.matcher(s);
                //判断此行是否为需要的行
                if(m.matches()) {
                    Matcher m1 = p1.matcher(str);
                    if(m1.find()){
                        System.out.println("m1 find");
                        MatchResult mr =   m1.toMatchResult();
                        System.out.println(mr.group(0));
                        System.out.println(m1.group(0));
                       
                        
                    }
                 
                }
                
                
                
//                //BufferedWriter out = new BufferedWriter();
//                String str = HttpInvokerUtil.invokeWithGetMethod("http://dict.cn/mini.php?q=test", null, "GBK");
//                BufferedReader br = new BufferedReader(new StringReader(str));
//                
//                String temp;
//                String purple = null;
//                boolean purpleFlag = false;
//                boolean contentFlag = false;
//                String content;
//                
//                StringBuilder sb = new StringBuilder();
//                while((temp = br.readLine()) != null){
//                    if(!purpleFlag && temp.contains("purple")){
//                         purple = temp.substring(temp.indexOf(">[")+2, temp.length()-6);
//                         purpleFlag = true;
//                    }
//                    if(!contentFlag && temp.contains("<div id=\"word-exp-block\" class=\"more\">")) {
//                        contentFlag = true;
//                        continue;
//                    }
//                    
//                    if(contentFlag && temp.contains("</div>")) {
//                      break;  
//                    }
//                    
//                    if(contentFlag && !temp.contains("br")) {
//                        sb.append(temp);
//                    }
//                    
//                    
//                }
//               
//                System.out.println(purple);
//                System.out.println(sb.toString());
            }
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}
